<?php

/**
 * Product form base class.
 *
 * @package    form
 * @subpackage product
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseProductForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'category_id'     => new sfWidgetFormDoctrineChoice(array('model' => 'Category', 'add_empty' => false)),
      'name'            => new sfWidgetFormInput(),
      'description'     => new sfWidgetFormTextarea(),
      'image'           => new sfWidgetFormInput(),
      'weight'          => new sfWidgetFormInput(),
      'manufacturer_id' => new sfWidgetFormInput(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorDoctrineChoice(array('model' => 'Product', 'column' => 'id', 'required' => false)),
      'category_id'     => new sfValidatorDoctrineChoice(array('model' => 'Category')),
      'name'            => new sfValidatorString(array('max_length' => 255)),
      'description'     => new sfValidatorString(array('max_length' => 2000)),
      'image'           => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'weight'          => new sfValidatorNumber(array('required' => false)),
      'manufacturer_id' => new sfValidatorInteger(),
      'created_at'      => new sfValidatorDateTime(array('required' => false)),
      'updated_at'      => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('product[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Product';
  }

}
